<template>
  <div class="main" v-color="'bgkImg'">
    <dz-nav :is-back="true" back-url="/my">
      <template #center>
        <b v-color><qq>SetLoginPassword</qq></b>
      </template>
    </dz-nav>
    <div class="box-1">
      <dz-input
          v-model="form.oldPassword"
          :rule="rule.oldPassword"
          :rule-label="$t('PleaseenterOldpassword')"
          type="password"
          :placeholder="$t('PleaseenterOldpassword')"
          :label="$t('OldPassword')"/>
      <dz-input
          v-model="form.newPassword"
          :rule="rule.newPassword"
          :rule-label="$t('PleaseenterNewpassword')"
          type="password"
          :placeholder="$t('PleaseenterNewpassword')"
          label="New password"/>
      <div class="bottom-btn">
        <dz-button @click="submit"><qq>confirm</qq></dz-button>
      </div>
      <dz-safe></dz-safe>
    </div>
  </div>
</template>

<script>
  import {changePassword} from "@/api/apiFox";
  import {Toast} from "vant";

  export default {
    data(){
      return{
        form:{newPassword:'',oldPassword:''},
        rule:{newPassword:false,oldPassword:false}
      }
    },
    methods:{
      submit(){
        if (this.form.oldPassword  === ''){
          this.rule.oldPassword=true
        }else if (this.form.newPassword===''){
          this.rule.newPassword=true
        }else{
          console.log(this.input)
          this.rule ={newPassword:false,oldPassword:false}
          changePassword(this.form).then(res=>{
            console.log(res)
            Toast.success(this.$t('Success'))
            this.$store.dispatch('removeLogins')
          }).catch(err=>{})
        }

      },
      phone(item){
        console.log(item)
      }
    },
  }
</script>

<style scoped lang="scss">
.main{
  width: 100%;
  min-height: 100vh;
  .box-1{
    width: 375px;
    min-height: calc(100vh - 50px);
    background: linear-gradient( 180deg, #FFF0C9 0%, #D49188 100%);
    border-radius: 30px 30px 0px 0px;
    padding: 35px 16px;
    box-sizing: border-box;
    position: relative;
    .bottom-btn{
      width: 100%;
      padding: 35px 16px;
      box-sizing: border-box;
      position: absolute;
      bottom: 30px;
      left: 0;
      .button{
        width: 100%;
        height: 50px;
        background: linear-gradient( 90deg, #973DF1 0%, #5134C3 100%);
        box-shadow: 0px 4px 4px 0px rgba(92,18,187,0.25), inset 0px 4px 4px 0px rgba(249,249,249,0.25);
        border-radius: 30px 30px 30px 30px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-weight: 800;
        font-size: 16px;

        color: #FFFFFF;
      }
    }

  }
}
</style>